package me.trytofeel.mapper;

import me.trytofeel.bean.Video;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

// DAO层 是一些访问 数据库的接口方法
public interface VideoMapper {
    // 增 删 改 查
    @Select("select video_id as videoId, video_title as videoTitle from mybatis.video")
    List<Video> selectAllVideos();

    @Select("select video_id as videoId, video_title as videoTitle from mybatis.video where video_id = #{id}")
    Video selectVideoById(int id);

    @Delete("delete from mybatis.video where video_id = #{id}")
    int deleteVideoById(int id);

    @Insert("insert into mybatis.video (video_title) value (#{videoTitle})")
    int insertOneVideo(Video video);

    @Update("update mybatis.video set video_title = #{videoTitle} where video_id = #{videoId}")
    int updateOneVideo(Video video);
}
